package com.bckj.freshnow.goods.controller;

import com.bckj.freshnow.goods.model.GoodsCategoryRequest;
import com.bckj.freshnow.goods.model.GoodsCategoryResponse;
import com.bckj.freshnow.goods.service.GoodsCategoryService;

import org.springframework.web.bind.annotation.*;

import com.bckj.fastboot.core.page.annotation.PageQuery;
import com.github.pagehelper.PageInfo;

import lombok.RequiredArgsConstructor;
import java.util.List;


/**
 * 商品分类表(GoodsCategory)表控制层
 *
 * @author makejava
 * @since 2025-04-21 16:22:23
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("goods-category")
public class GoodsCategoryController {
    /**
     * 服务
     */
	private final GoodsCategoryService goodsCategoryService;
	
    /**
	 * 列表
	 *
	 * @param request req
	 * @return list
	 */
	@PageQuery
	@GetMapping("page")
	public PageInfo<GoodsCategoryResponse> page(GoodsCategoryRequest request) {
		List<GoodsCategoryResponse> data = goodsCategoryService.findAll(request);
		return new PageInfo<>(data);
	}
	
    /**
	 * 列表
	 *
	 * @param request req
	 * @return list
	 */
	@GetMapping("list")
	public List<GoodsCategoryResponse> list(GoodsCategoryRequest request) {
		return goodsCategoryService.findAll(request);
	}

	/**
	 * 增加
	 *
	 * @param request req
	 * @return boolean
	 */
	@PostMapping
	public boolean save(@RequestBody GoodsCategoryRequest request) {
		return goodsCategoryService.saveGoodsCategory(request);
	}

	/**
	 * 修改
	 *
	 * @param request req
	 * @return boolean
	 */
	@PutMapping
	public boolean update(@RequestBody GoodsCategoryRequest request) {
		return goodsCategoryService.updateGoodsCategory(request);
	}

	/**
	 * 移除
	 *
	 * @param id id
	 * @return boolean
	 */
	@DeleteMapping("{id}")
	public boolean remove(@PathVariable Long id) {
		return goodsCategoryService.remove(id);
	}

	/**
	 * 详情
	 *
	 * @param id id
	 * @return response
	 */
	@GetMapping("{id}")
	public GoodsCategoryResponse details(@PathVariable Long id) {
		return goodsCategoryService.details(id);
	}
}

